package org.millenaire_reborn.init;

import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.ToolMaterial;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.millenaire_reborn.MillenaireReborn;
import org.millenaire_reborn.annotations.AutoItem;
import org.millenaire_reborn.item.ModToolMaterials;

// 模组物品注册
public class ModItems {

    public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MillenaireReborn.MOD_ID);

    // 基础物品
    @AutoItem(en = "Denier", zh = "迪奈尔铜币")
    public static DeferredItem<Item> DENIER = ITEMS.registerSimpleItem("denier");
    @AutoItem(en = "Silk", zh = "丝绸")
    public static DeferredItem<Item> SILK = ITEMS.registerSimpleItem("silk");
    @AutoItem(en = "Denier Or", zh = "迪奈尔金币")
    public static DeferredItem<Item> DENIER_OR = ITEMS.registerSimpleItem("denier_or");
    @AutoItem(en = "Denier Argent", zh = "迪奈尔银币")
    public static DeferredItem<Item> DENIER_AGENT = ITEMS.registerSimpleItem("denier_argent");
    @AutoItem(en = "Obsidian Flake", zh = "黑曜石片")
    public static DeferredItem<Item> OBSIDIAN_FLAKE = ITEMS.registerSimpleItem("obsidian_flake");
    @AutoItem(en = "Unknown Powder", zh = "不明粉末")
    public static DeferredItem<Item> UNKNOWN_POWDER = ITEMS.registerSimpleItem("unknown_powder");
    @AutoItem(en = "Byzantine Wool Clothes", zh = "拜占庭羊毛编织衣")
    public static DeferredItem<Item> BYZANTINE_WOOL_CLOTHES = ITEMS.registerSimpleItem("byzantine_wool_clothes");
    @AutoItem(en = "Byzantine Silk Clothes", zh = "拜占庭丝绸编织衣")
    public static DeferredItem<Item> BYZANTINE_SILK_CLOTHES = ITEMS.registerSimpleItem("byzantine_silk_clothes");
    @AutoItem(en = "Galianite Dust", zh = "方铅矿粉末")
    public static DeferredItem<Item> GALIANITE_DUST = ITEMS.registerSimpleItem("galianite_dust");
    @AutoItem(en = "Calva", zh = "苹果白兰地酒")
    public static DeferredItem<Item> CALVA = ITEMS.registerSimpleItem("calva");
    @AutoItem(en = "Tripes", zh = "牛肚")
    public static DeferredItem<Item> TRIPES = ITEMS.registerSimpleItem("tripes");
    @AutoItem(en = "Boudin", zh = "黑香肠")
    public static DeferredItem<Item> BOUDIN = ITEMS.registerSimpleItem("boudin");

    // 工具
    @AutoItem(en = "Norman Pickaxe", zh = "诺曼镐", type = "tool")
    public static DeferredItem<Item> NORMAN_PICKAXE =
            registerPickaxe("norman_pickaxe", ModToolMaterials.NORMAN);
    @AutoItem(en = "Norman Axe", zh = "诺曼斧", type = "tool")
    public static DeferredItem<Item> NORMAN_AXE =
            registerAxe("norman_axe", ModToolMaterials.NORMAN);
    @AutoItem(en = "Norman Shovel", zh = "诺曼锹", type = "tool")
    public static DeferredItem<Item> NORMAN_SHOVEL =
            registerShovel("norman_shovel", ModToolMaterials.NORMAN);
    @AutoItem(en = "Norman Hoe", zh = "诺曼锄", type = "tool")
    public static DeferredItem<Item> NORMAN_HOE =
            registerHoe("norman_hoe", ModToolMaterials.NORMAN);
    @AutoItem(en = "Norman Broadsword", zh = "诺曼宽剑", type = "tool")
    public static DeferredItem<Item> NORMAN_BROADSWORD =
            registerSword("norman_broadsword", ModToolMaterials.NORMAN);
    @AutoItem(en = "Norman Sword", zh = "诺曼剑", type = "tool")
    public static DeferredItem<Item> NORMAN_SWORD =
            registerSword("norman_sword", ModToolMaterials.NORMAN);

    // 作物
    @AutoItem(en = "Rice", zh = "稻米")
    public static DeferredItem<Item> RICE = ITEMS.registerSimpleItem("rice");
    @AutoItem(en = "Turmeric", zh = "姜黄")
    public static DeferredItem<Item> TURMERIC = ITEMS.registerSimpleItem("turmeric");

    private static DeferredItem<? extends Item> registerItem(String name, Item item) {
        return ITEMS.register(name, resourceLocation -> item);
    }

    private static DeferredItem<Item> registerPickaxe(String name, ToolMaterial material) {
        return ITEMS.registerItem(name, props -> new PickaxeItem(material, 1.0F, -2.8F, props));
    }

    private static DeferredItem<Item> registerAxe(String name, ToolMaterial material) {
        return ITEMS.registerItem(name, props -> new AxeItem(material, 6.0F, -3.1F, props));
    }

    private static DeferredItem<Item> registerShovel(String name, ToolMaterial material) {
        return ITEMS.registerItem(name, props -> new ShovelItem(material, 1.5F, -3.0F, props));
    }

    private static DeferredItem<Item> registerHoe(String name, ToolMaterial material) {
        return ITEMS.registerItem(name, props -> new HoeItem(material, -2.0F, -1.0F, props));
    }

    private static DeferredItem<Item> registerSword(String name, ToolMaterial material) {
        return ITEMS.registerItem(name, props -> new SwordItem(material, 3.0F, -2.4F, props));
    }
}
